var app = getApp()
Page({
  /**
   * 页面的初始数据
   */
  data: {
    ifShownoData: true,
    picArr: [],
    siteOrderId: ''
  },
  getPicture: function() {
    var that = this
    wx.showLoading({ title: '加载中' })
    wx.request({
      method: 'POST',
      url: app.preUrl + 'getSiteOrderImg',
      dataType: 'json',
      header: {
        'content-type': 'application/x-www-form-urlencoded'
      },
      data: {
        siteOrderId: that.data.siteOrderId
      },
      success: function(res) {
        wx.hideLoading()
        if (res.data.code == 100) {
          let data = res.data.result
          console.log(data)
          if (data.length) {
            that.setData({ ifShownoData: true, picArr: data })
          } else {
            that.setData({ ifShownoData: false, picArr: [] })
            wx.showModal({
              title: '提示',
              content: '没有上传过相关图片',
              confirmColor: '#56BDE0',
              showCancel: false,
              success(res) {
                if (res.confirm) {
                  wx.navigateBack({
                    delta: 1
                  })
                }
              }
            })
          }
        } else {
          wx.showModal({
            title: '提示',
            content: res.data.message,
            confirmColor: '#56BDE0',
            showCancel: false
          })
        }
      },
      fail: function(error) {}
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    console.log(options)
    this.setData({ siteOrderId: options.id })
    this.getPicture()
  }
})
